﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using HA.ModFlow.Domain.DomainLayer;
namespace HA.ModFlow.Controls.Windows
{
    /// <summary>
    /// winDE4.xaml 的交互逻辑
    /// </summary>
    public partial class winDE4 : Window
    {
        public winDE4(DESolver DEsolver)
        {
            InitializeComponent();
            this.Des = (DESolver)DEsolver.Clone();
            this.rbtnITMXN.Click += new RoutedEventHandler(rbtnITMXN_Click);
            this.rbtnITMXY.Click += new RoutedEventHandler(rbtnITMXN_Click);
        }

        void rbtnITMXN_Click(object sender, RoutedEventArgs e)
        {
            if (rbtnITMXN.IsChecked.Value)
            {
                this.cboIFREQ.IsEnabled = true;
                this.txtITMX.IsEnabled = false;
                this.txtACCL.IsEnabled = false;
                this.txtHCLOSE.IsEnabled = false;
            }
            else
            {
                this.cboIFREQ.IsEnabled = false;
                this.txtITMX.IsEnabled = true;
                this.txtACCL.IsEnabled = true;
                this.txtHCLOSE.IsEnabled = true;
            }
        }
        private DESolver _Des;

        public DESolver Des
        {
            get { return _Des; }
            set { _Des = value; }
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            if (this.Des.ITMXb)
            {
                this.rbtnITMXN.IsChecked = true;              
            }
            else
            {
                this.rbtnITMXY.IsChecked = true;               
            }
            rbtnITMXN_Click(sender, e);
            this.cboIFREQ.SelectedIndex = this.Des.IFREQ - 1;
            this.cboMUTD4.SelectedIndex = this.Des.MUTD4 ;
            this.DataContext = this.Des;

        }

        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            this.Des.IFREQ = this.cboIFREQ.SelectedIndex + 1;
            this.Des.MUTD4 = this.cboMUTD4.SelectedIndex ;
            this.DialogResult = true;
            this.Close();
        }
    }
}
